/**
 * @description 复制文本
 * @param {String} text 要复制的文本
 */
interface CopyFunction {
	(text: string): void;
}

const copy: CopyFunction = text => {
	let copyContent = text;
	var input = document.createElement('input');
	input.setAttribute('value', copyContent);
	document.body.appendChild(input);
	if (input.setSelectionRange) {
		input.focus();
		input.setSelectionRange(0, -1); // 全选
	} else {
		input.select();
	}
	document.execCommand('copy');
	document.body.removeChild(input);
};
export default copy;
